package com.hnkywl.sts.filter;

import org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter;

import javax.servlet.FilterChain;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;

/**
 * Created with IntelliJ IDEA.
 * User: Administrator
 * Date: 13-5-22
 * Time: 下午12:06
 */
public class PlusStrutsPrepareAndExecuteFilter extends StrutsPrepareAndExecuteFilter {

    public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException, ServletException {
        HttpServletRequest request = (HttpServletRequest) req;
        //不过滤的url，可以自行添加
        String uri = request.getRequestURI();
        boolean isSkip = false;
        isSkip = isSkip || uri.contains("/services");
        isSkip = isSkip || uri.contains("/servlet");
        isSkip = isSkip || uri.contains(".jws");
        isSkip = isSkip || uri.contains("/axis2-admin");
        if (isSkip) {
            //应用自定义的过滤器
            chain.doFilter(req, res);
        } else {
            super.doFilter(request, res, chain);
        }
    }

}
